#include<stdio.h>
#include<string.h>

void Exchange(char*s,int len)
{
    for(int i=0;i<len/2;i++)
    {
        char temp=s[i];
        s[i]=s[len-i-1];
        s[len-i-1]=temp;
    }   
}

void Exchange2(char*s)
{
    int len=0;
    for(int i=0;i<strlen(s);i++)
    {
        if(s[i]==' '||s[i]=='\0')
        {
            Exchange(s+i-len,len);
            len=0;
        }
        else
        {
            len++;
        }
    }
}

int  main()
{
    char s[]="i am from nanjing";
    char *p=s;
    Exchange(p,strlen(p));
    printf("%s\n",p);
    Exchange2(p);
    printf("%s\n",p);
    return 0;
}